import React from "react";

// 评论列表组件
const List = (props) => {
  console.log("接收父组件的数据：", props);
  const { list } = props;
  // 评论列表渲染
  const renderList = () => {
    // 获取列表状态数据
    // const list = [];
    return list.length ? (
      list.map((item) => (
        <li key={item.id}>
          <p className="pline">{item.name}</p>
          <p>{item.content}</p>
        </li>
      ))
    ) : (
      <li className="nodata">
        <p>暂无数据！</p>
      </li>
    );
  };
  return <ul className="list">{renderList()}</ul>;
};

export default List;
